<%@page import="utility.DateTool"%>
<%@page import="model.dto.Manager"%>
<%@page import="model.dto.League"%>
<%@page import="java.util.ArrayList"%>
<%@page import="model.dto.Country"%>
<jsp:include page="include/header.jsp"/>		
		

		<div class="wrapper">
			<!-- BEGIN TOP NAV -->
			<jsp:include page="include/sidebar-top.jsp"/>
			<!-- END TOP NAV -->
			
			<!-- BEGIN SIDEBAR LEFT -->
			<jsp:include page="include/sidebar-left.jsp"/>
			<!-- END SIDEBAR LEFT -->
			
			
			<!-- BEGIN SIDEBAR RIGHT -->
			<jsp:include page="include/sidebar-right.jsp"/>
			<!-- END SIDEBAR RIGHT -->
			
			
			<!-- BEGIN PAGE CONTENT -->
			<div class="page-content">
				<div class="container-fluid">
				
<!--============================================= Add your content here ========================================-->
					
					
				
					<!-- Begin page heading -->
					<h1 class="page-heading">ADD MANAGER <small>manager</small></h1>
					<!-- End page heading -->

		<div class="row"> 
						 <div class="col-sm-3 col-md-3">
							<a href="#fakelink" class="thumbnail">
						  		<img src="assets/img/photo/small/img-1.jpg" alt="Image" id="image_thumbnail">
							</a>
					  	</div><!-- /.ol-xs-6 col-md-3 -->
						<div class="col-sm-8">
							<div class="panel panel-info">
							  <div class="panel-heading">
								<h3 class="panel-title">Manager</h3>
							  </div>
							  <div class="panel-body">
								<form id="form" class="form-horizontal" onsubmit="return checkNull()&&checkOption();" action="add-manager-process.sp" method="post" enctype="multipart/form-data">
									<fieldset>
										<legend></legend>
										<div class="form-group">
											<label class="col-lg-3 control-label">Nationality</label>
											<div class="col-lg-9">
												<select id="country_id" name="country_id"  class="col-lg-12 form-control">
													
												</select>
											</div>
										</div>
										<input type="hidden" id="manager_id" name="manager_id">
										<div class="form-group">
											<label class="col-lg-3 control-label">Name<span class="text-danger">*</span></label>
											<div class="col-lg-9">
												<input type="text" class="form-control require" id="manager_name" name="manager_name" />
											</div>
										</div>
										<div class="form-group">
											<label class="col-lg-3 control-label">Date of Birth<span class="text-danger">*</span></label>
											<div class="col-lg-9" style="padding:0px">
												<!-- <input type="text" class="form-control add-on required" id="manager_date_of_birth" name="manager_date_of_birth" data-format="dd-MM-yyyy" placeholder="dd-MM-yyyy" /> -->
												<div class="col-lg-4">
													<select id="month" name="month"  class="form-control require-select" tabindex="2">
														<option value="-1">Month</option>
														
													</select>
												</div>
												<div class="col-lg-4">
													<select id="day" name="day"  class="form-control require-select" tabindex="2">
														<option value="-1">Day</option>
														
													</select>
												</div>
												<div class="col-lg-4">
													<select id="year" name="year"  class="form-control require-select" tabindex="2">
														<option value="-1">Year</option>
														
													</select>
												</div>
											</div>
										</div>
										<div class="form-group">
											<label class="col-lg-3 control-label">Image</label>
											<div class="col-lg-9">
													<div class="input-group">
														<input type="text" class="form-control" id="manager_image" name="manager_image" readonly>
														<span class="input-group-btn">
															<span class="btn btn-default btn-file" id="image_browser">
																Browse&hellip; <input type="file" name="abc1">
															</span>
														</span>
													</div><!-- /.input-group -->
											</div>
										</div>
										<div class="form-group">
											<label class="col-lg-3 control-label"></label>
											<div class="col-lg-9">
													<div class="input-group pull-right">
														<a  href="index.sp" class="btn btn-warning btn-perspective ">Cancel</a>&nbsp;
														<button id="btn_send" class="btn btn-info btn-perspective ">Save</button>
													</div><!-- /.input-group -->
											</div>
										</div>
									</fieldset>

																
								</form>
								
							  </div><!-- /.panel-body -->
							  <div class="panel-footer">
							  	
							  </div>
							</div><!-- /.panel panel-info -->
						</div><!-- /.col-sm-4 -->
		</div>
		
		
		
		<%
					Manager dto=(Manager)request.getAttribute("dto");
					int pageNumber=1;
					if(request.getAttribute("page")!=null){
						pageNumber=Integer.parseInt(request.getAttribute("page").toString());
					}
		%>
		
		
		<%if(dto!=null){
			int day=0,month=0,year=0;
				DateTool.setValue(DateTool.getString(dto.getDateOfBirth()));
				day=DateTool.day;
				month=DateTool.month;
				year=DateTool.year;
			
		%>
		<script type="text/javascript">
			$(document).ready(function(){
				$.post("get-all-country.sp", {
				}, function(data) {
					createOptionByJson(document.getElementById("country_id"),data,<%=dto.getCountryId()%>);		
			});
				
				createOption(document.getElementById("day"), 1, 31,<%=day%>);
				createOption(document.getElementById("month"), 1, 12,<%=month%>);
				createOption(document.getElementById("year"), 1940, 2000,<%=year%>);
				document.getElementById("manager_id").value="<%=dto.getId()%>";
				document.getElementById("manager_name").value="<%=dto.getName()%>";
				document.getElementById("manager_image").value="<%=dto.getImage()%>";
				document.getElementById("btn_send").innerHTML="Update";
				document.getElementById("form").action="update-manager-process.sp?page="+<%=pageNumber%>;
				document.getElementById("image_thumbnail").src="../upload/manager/<%=dto.getImage()%>";
			});
		</script>
		<%} else{%>
			<script type="text/javascript">
			$(document).ready(function(){
				$.post("get-all-country.sp", {
				}, function(data) {
					createOptionByJson(document.getElementById("country_id"),data,"");		
			});
				
				createOption(document.getElementById("day"), 1, 31,"");
				createOption(document.getElementById("month"), 1, 12,"");
				createOption(document.getElementById("year"), 1940, 2000,"");
			});
		</script>
		<%} %>
					
					
					
					
					
<!--============================================ End your content ============================================-->
				
					
				</div><!-- /.container-fluid -->
				

				<!-- BEGIN SIDEBAR BOTTOM -->
				<jsp:include page="include/sidebar-bottom.jsp"/>
				<!-- END SIDEBAR BOTTOM -->
				
				
			</div><!-- /.page-content -->
		</div><!-- /.wrapper -->
		<!-- END PAGE CONTENT -->


<jsp:include page="include/footer.jsp"/>			
				
				
